#!./perl
#Includes cgi-lib file; if cgi-lib doesn't exist, returns malformed
#header error
do "cgi-lib.pl" || die "Fatal Error: Can't load cgi library";
#calls the subroutine in the cgi-lib.pl library
#to read in the variables from the form and set them up
#as key=value pairs in the array @in
&ReadParse;
#tells http server incoming data is text html
print "Content-type: text/html\n\n";
#returns acknowledgment of mail submission and provides a link back
print "<HTML>";
print "<HEAD><TITLE>Thank You\!</TITLE>";
print "</HEAD><BODY>";
print "<H2>Thank you\!</H2>";
print "<P>";
print "We've mailed off your information.";
print "<HR>";
print "<H3>Back to the <A HREF=\"/index.html\">";
print "Home Page</A></H3>";
print "</BODY></HTML>";
#assigns process id to $pid
$pid=$$;
#opens up comment file for writing
open(COMMENTSFILE,">/tmp/my_comment.$pid");
#enter the form data into the file to be mailed
print COMMENTSFILE "CONTACT MAILING LIST REPORT\n";
print COMMENTSFILE "- - - - - - - - - - - - - - - - - -\n";

print COMMENTSFILE "\"$in{'first_name'}\",\"$in{'last_name'}\",\"$in{'title'}\",\"$in{'org'}\",\"$in{'address'}\",";
print COMMENTSFILE "\"$in{'mailstop'}\",\"$in{'city'}\",\"$in{'state'}\",\"$in{'zip'}\",\"$in{'country'}\",";
print COMMENTSFILE "\"$in{'phone'}\",\"$in{'fax'}\",\"$in{'email'}\"\n";
print COMMENTSFILE "\"$in{'info_action'}\",\"$in{'mcad'},\"$in{'mcad-seats'}\",\"$in{'ecad'}\",\"$in{'ecad-seats'}\",";
print COMMENTSFILE "\"$in{'tpubs'}\",\"$in{'tpubs-seats'}\",\"$in{'solution'}\",\"$in{'solution-other'}\",";
print COMMENTSFILE "\"$in{'platform'}\",\"$in{'need-timeframe'}\"";
#close out file to be mailed
close COMMENTSFILE;
#sends comment file as mail to user
$command="/usr/ucb/mail cdcatalyst@workgroup.com < /tmp/my_comment.$pid";
system($command);
#erases temp file
unlink("/tmp/my_comment.$pid");

